package com.cashbox.dao.conexiones;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;

/**
 *
 * @author luramirez
 */
public class ConexionFactory {
    
    private static ConexionFactory conexion;
    private EntityManager entitiManager;

    private ConexionFactory() {
         this.entitiManager = Persistence.createEntityManagerFactory("CashBoxPU").createEntityManager();
         this.entitiManager.getTransaction().begin();
    }
    
   
    public static ConexionFactory getInstance(){
        if(conexion == null){
           conexion = new ConexionFactory();
        }
        return conexion;
    }

    /**
     * @return the entitiManager
     */
    public EntityManager getEntitiManager() {
        return entitiManager;
    }

    /**
     * @param entitiManager the entitiManager to set
     */
    public void setEntitiManager(EntityManager entitiManager) {
        this.entitiManager = entitiManager;
    }
    
    
}
